home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Burning & Media / GB-PVR 1.2.13 / GBPVR10213.msi / Cabs.w1.cab / ManualRecord.aspx.cs429 < prev    next >
Text File  |  2007-12-14  |  8KB  |  206 lines

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using GBPVRSchedule;
  12. using gbweb.classes;
  13. using GBPVR.Public;
  14.  
  15.  
  16. namespace gbweb
  17. {
  18.     public partial class Migrated_ManualRecord : ManualRecord
  19.     {
  20.         private Settings guideParams;
  21.  
  22.         protected void Page_Load(object sender, EventArgs e)
  23.         {
  24.             getTheme();
  25.  
  26.             if (!IsPostBack)
  27.             {
  28.                 //Load the settings from the config file
  29.                 guideParams = Global.Settings;
  30.  
  31.                 //Fill the drop down list of channels
  32.                 Global.FillChannelList(listChannels);
  33.  
  34.                 //Set the default name for the recording...display class will provide "Manual Recording"
  35.                 //if this field remains null
  36.                 pgmName.Text = null;
  37.  
  38.                 //Set the default recording Quality
  39.                 quality.SelectedValue = guideParams.recordingQuality;
  40.  
  41.                 //Default the start date to today
  42.                 startDate.SelectedDate = DateTime.Now;
  43.  
  44.                 //Default the start time to now
  45.                 startTime.SelectedTime = DateTime.Now;
  46.                 
  47.                 //Default the stop time to 1 hour from the start time
  48.                 endTime.SelectedTime = DateTime.Now.AddHours(1);
  49.  
  50.                 //Ensure the error message box is not displaying
  51.                 RecordMessage.Visible = false;
  52.             }
  53.  
  54.         }
  55.         protected void LinkButton1_Click(object sender, EventArgs e)
  56.         {
  57.             bool scheduleReturn = true;
  58.  
  59.             //Create a Programme
  60.             Programme dummyPgm = new Programme();
  61.  
  62.             //Set the channel that is to be recorded
  63.             dummyPgm.setChannelOID(System.Convert.ToInt32(listChannels.SelectedValue));
  64.  
  65.             //Set the start time for for programme to record
  66.             string sDate = startDate.SelectedDate.ToShortDateString();
  67.             string sTime = startTime.SelectedTime.ToShortTimeString();
  68.             DateTime fullStartDate = Convert.ToDateTime(sDate + " " + sTime);
  69.             dummyPgm.setStartTime(fullStartDate);
  70.  
  71.             //Set the end time for the programme to record
  72.             string eDate = startDate.SelectedDate.ToShortDateString();
  73.             string eTime = endTime.SelectedTime.ToShortTimeString();
  74.             DateTime fullEndDate = Convert.ToDateTime(eDate + " " + eTime);
  75.  
  76.             //Update the end date if the recording spans two different dates
  77.             if (fullEndDate.Hour < fullStartDate.Hour)
  78.             {
  79.                 fullEndDate = fullEndDate.AddDays(1);
  80.             }
  81.             dummyPgm.setEndTime(fullEndDate);
  82.  
  83.             if (pgmName.Text.Length > 0)
  84.             {
  85.                 dummyPgm.setTitle(pgmName.Text);
  86.             }
  87.  
  88.             //Create the recording
  89.             //scheduleReturn = myschedule.ManualSchedule(dummyPgm, recQuality);
  90.  
  91.             Schedule.Quality quality = 0;
  92.             int prePad = Convert.ToInt32(prePadding.Text);
  93.             int postPad = Convert.ToInt32(postPadding.Text);
  94.             switch (Request.Params["quality"].ToLower())
  95.             {
  96.                 case "high":
  97.                     quality = Schedule.Quality.High;
  98.                     break;
  99.  
  100.                 case "medium":
  101.                     quality = Schedule.Quality.Medium;
  102.                     break;
  103.  
  104.                 case "low":
  105.                     quality = Schedule.Quality.Low;
  106.                     break;
  107.  
  108.                 case "custom1":
  109.                     quality = Schedule.Quality.Custom1;
  110.                     break;
  111.  
  112.                 case "custom2":
  113.                     quality = Schedule.Quality.Custom2;
  114.                     break;
  115.             }
  116.  
  117.             if (radioDay.SelectedValue == "once")
  118.             {
  119.                 // schedule one-off recording
  120.                 Schedule myschedule = Global.Schedule;
  121.                 scheduleReturn = myschedule.ScheduleOnce(dummyPgm, quality, prePad, postPad);
  122.             }
  123.             else
  124.             {
  125.                 //Schedule Season Recordings
  126.                 //Set the max number of recordings to keep for the show
  127.                 int keepnumRecordings = ReoccuringRecordingExtras.KEEP_ALL_FILES;
  128.                 if (keepRecordings.Text.ToString() != null)
  129.                 {
  130.                     try
  131.                     {
  132.                         keepnumRecordings = System.Convert.ToInt32(keepRecordings.Text);
  133.                     }
  134.                     catch
  135.                     {
  136.                         keepnumRecordings = ReoccuringRecordingExtras.KEEP_ALL_FILES;
  137.                     }
  138.                 }
  139.                 else
  140.                 {
  141.                     keepnumRecordings = ReoccuringRecordingExtras.KEEP_ALL_FILES;
  142.                 }
  143.  
  144.                 Schedule myschedule = Global.Schedule;
  145.  
  146.                 // schedule manual recording for every day of the week
  147.                 if (radioDay.SelectedValue == "everyDay")
  148.                 {
  149.                     scheduleReturn = myschedule.ScheduleThisTime(dummyPgm, quality, Schedule.DayType.SheduleAnyDay, keepnumRecordings, Schedule.RecType.Daily, prePad, postPad);
  150.                 }
  151.                 // schedule manual recording for this day on each week
  152.                 else if (radioDay.SelectedValue == "everyWeek")
  153.                 {
  154.                     scheduleReturn = myschedule.ScheduleThisTime(dummyPgm, quality, Schedule.DayType.SheduleThisDay, keepnumRecordings, Schedule.RecType.Weekly, prePad, postPad);
  155.                 }
  156.                 // schedule manual recording for weekdays
  157.                 else if (radioDay.SelectedValue == "weekDays")
  158.                 {
  159.                     scheduleReturn = myschedule.ScheduleThisTime(dummyPgm, quality, Schedule.DayType.SheduleThisDay, keepnumRecordings, Schedule.RecType.WeekDays, prePad, postPad);
  160.                 }
  161.                 // schedule manual recording for weekends
  162.                 else if (radioDay.SelectedValue == "weekEnd")
  163.                 {
  164.                     scheduleReturn = myschedule.ScheduleThisTime(dummyPgm, quality, Schedule.DayType.SheduleThisDay, keepnumRecordings, Schedule.RecType.WeekEnds, prePad, postPad);
  165.                 }
  166.             }
  167.  
  168.             //Display error message if recording does not schedule
  169.             if (scheduleReturn)
  170.             {
  171.                 // close popup details window
  172.                 Page.RegisterStartupScript("startupScript", "<script language=JavaScript>reloadAndClose();</script>");
  173.             }
  174.             else
  175.             {
  176.                 RecordMessage.Text = "Recording Failed!";
  177.                 RecordMessage.Visible = true;
  178.             }
  179.         }
  180.  
  181.         private void getTheme()
  182.         {
  183.             string theme = System.Convert.ToString(Session["theme"]);
  184.  
  185.             if (theme != null && theme != "")
  186.             {
  187.                 return;
  188.             }
  189.             else
  190.             {
  191.                 HttpCookie cookie = Request.Cookies["theme"];
  192.                 if (cookie != null && cookie.Value.Length > 0)
  193.                 {
  194.                     theme = cookie.Value;
  195.                 }
  196.                 else
  197.                 {
  198.                     theme = "Default";
  199.                 }
  200.                 Session["theme"] = "themes/" + theme;
  201.                 return;
  202.             }
  203.         }
  204. }
  205. }
  206.